import 'package:flutter/material.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/pages/post/cardmine/post_list_normal_widget_page.dart';
import 'package:flutterlib/widgets/quhui_tabbar_widget.dart';
import 'package:flutterlib/widgets/round_underline_tabindicator.dart';
import 'package:thrio/thrio.dart';


class Page extends StatefulWidget {
  Page({Key key}) : super(key: key);

  @override
  PageState createState() => PageState();
}

class PageState extends State<Page>
    with SingleTickerProviderStateMixin {
  final SettingsStore store =
      Provider.of<SettingsStore>(currentContext, listen: false);
  List<Widget> tabPageView = new List();
  List<Widget> tabViews = new List();
  Map<int, PostNormalListWidgetPage> pages = {};

  @override
  void initState() {
    super.initState();

    tabPageView.add(new PostNormalListWidgetPage(
      name: "已发布",
      type: 0,
    ));
    tabViews.add(renderItem("已发布", 0));

    tabPageView.add(new PostNormalListWidgetPage(
      name: "待审核",
      type: 1,
    ));
    tabViews.add(renderItem("待审核", 0));
    tabPageView.add(new PostNormalListWidgetPage(
      name: "已拒绝",
      type: 2,
    ));
    tabViews.add(renderItem("已拒绝", 0));
  }

  renderItem(String item, int i) {
    return VgTab(
      child: new Text(
        item,
        style: QuhuiConstant.smallSubText,
        maxLines: 1,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    print(context.widget.toStringShort());


      ///绘制顶部 tab 控件
      return new QuhuiTabBarWidget(
        type: TabType.top,
        tabItems: tabViews,
        tabBarType: 1,
        resizeToAvoidBottomPadding: false,
        tabViews: tabPageView,
        backgroundColor: QuhuiColors.mainBackgroundColor,
        indicatorColor: QuhuiColors.mainThemeColor,
        title: Text('我的文章', style: QuhuiConstant.normalTextBold),
        leading: Material(
          color: Colors.transparent,
          child: InkWell(
            borderRadius: const BorderRadius.all(
              Radius.circular(32.0),
            ),
            onTap: () {
              ThrioNavigator.pop();
            },
            child: Icon(
              Icons.arrow_back,
              color: Colors.black,
            ),
          ),
        ),
        onPageChanged: (index) {},
      );
  }

}
